import Vue from 'vue'
import Vuex from 'vuex'
import axios from './http'
Vue.use(Vuex)
const store = new Vuex.Store({
    state: {
        banner_list: []
    },
    mutations: {
        bannerMutations(state,obj){
            state.banner_list = obj
        }
    },
    actions: {
        bannerActions(context){
            axios.get("/getbanner").then(res=>{
                context.commit("bannerMutations",res.list)
            })
        },
    },
    getters: {
        banner_number(state){
            return state.banner_list.length
        }
    }//类型computed是一个计算属性
}) //声明一个vuex的存储实例
export default store